﻿using OASystem.BLL.IService;
using OASystem.DAL;
using OASystem.Model;
using OASystem.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace OASystem.BLL.Service
{
    //记得修改Userinfo成自己要使用的实体
    public class PartService : BaseRepository<Departinfo>, IPartService
    {
        /// <summary>
        /// 查询部门集合
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public ResponseResult QueryDepart(string username)
        {
            ResponseResult responseResult = new ResponseResult();

            responseResult.code = 0;
            responseResult.msg = string.Empty;
            int count = 0;
            Expression<Func<Departinfo, bool>> whereLambda = a => true;
            if (!string.IsNullOrEmpty(username))
            {
                whereLambda = a => a.DepartName.Equals(username);
            }
            responseResult.data = QueryList(whereLambda);
            responseResult.count = count;
            return responseResult;
        }
        /// <summary>
        /// 显示编辑数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ResponseResult Update(int id)
        {
            ResponseResult responseResult = new ResponseResult();

            Expression<Func<Departinfo, bool>> whereLambda = a => a.DepartId == id;
            if (Query(whereLambda) != null)
            {
                responseResult.success = true;
            }

            responseResult.data = Query(whereLambda);
            return responseResult;
        }
    }
}
